<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>字符串操作方法</title>
    <script>
        //字符串操作方法
        //1.concat('str1','str2',...);将多个字符串连接到一起
        var str1 = 'andy';
        console.log(str1.concat('red'));
        //2.substr(截取的起始位置,截取的长度(几个字符));
        var str2 = '改革春风吹满地';
        console.log(str2.substr(2,3));
        
        //3.替换字符
        //replace('被替换的字符','替换为的字符');
        console.log(str1.replace('a','b'));
        //注意,只替换查找到的第一个字符,后续重复出现也不替换
        //4.字符串转换为数组
        //split('字符串里的分隔符')
        var str3 = 'red&yellow&green';
        console.log(str3.split('&'));

    </script>
</head>
<body>
    
</body>
</html>